package scalapackage.testfanxing

/**
  * Created by Germmy on 2018/4/16.
  */
class ContextBoundDemo[T: Ordering] {//为啥这个地方Ordering后面又不加T了呢？真尼玛诡异，可以加的
  def selectGirl(g1: T, g2: T): T = {
    val ord: Ordering[T] = implicitly[Ordering[T]]
    if (ord.gt(g1, g2)) g1 else g2
  }
}

object ContextBoundDemo {
  def main(args: Array[String]) {
    import testimplicit.MyPreDef.OrderingGirl
    val cbd = new ContextBoundDemo[MyGirl]
    val g1=new MyGirl("daya",40,90)
    val g2=new MyGirl("erya",39,90)
    val res=cbd.selectGirl(g1,g2)
    println(res.name)
  }
}
